package c.c.b.a.b;

import b.i.b.f;
import java.net.URL;
import java.util.Objects;

/* compiled from: Request */
public final class c0 {
    public final w a;
    public final String b;
    public final v c;
    public final e0 d;
    public final Object e;
    public volatile i f;

    /* compiled from: Request */
    public static class a {
        public w a;
        public String b;
        public c.c.b.a.b.v.a c;
        public e0 d;
        public Object e;

        public a() {
            this.b = "GET";
            this.c = new c.c.b.a.b.v.a();
        }

        public a a() {
            d("GET", null);
            return this;
        }

        public a b(w wVar) {
            Objects.requireNonNull(wVar, "url == null");
            this.a = wVar;
            return this;
        }

        public a c(String str) {
            Objects.requireNonNull(str, "url == null");
            StringBuilder g;
            if (str.regionMatches(true, 0, "ws:", 0, 3)) {
                g = c.b.a.a.a.g("http:");
                g.append(str.substring(3));
                str = g.toString();
            } else {
                if (str.regionMatches(true, 0, "wss:", 0, 4)) {
                    g = c.b.a.a.a.g("https:");
                    g.append(str.substring(4));
                    str = g.toString();
                }
            }
            c.c.b.a.b.w.a aVar = new c.c.b.a.b.w.a();
            w wVar = null;
            if (aVar.a(null, str) == c.c.b.a.b.w.a.a.SUCCESS) {
                wVar = aVar.b();
            }
            if (wVar != null) {
                b(wVar);
                return this;
            }
            throw new IllegalArgumentException(c.b.a.a.a.D("unexpected url: ", str));
        }

        public a d(String str, e0 e0Var) {
            if (str.length() != 0) {
                String str2 = "method ";
                if (e0Var != null && !f.H(str)) {
                    throw new IllegalArgumentException(c.b.a.a.a.E(str2, str, " must not have a request body."));
                } else if (e0Var == null && f.A(str)) {
                    throw new IllegalArgumentException(c.b.a.a.a.E(str2, str, " must have a request body."));
                } else {
                    this.b = str;
                    this.d = e0Var;
                    return this;
                }
            }
            throw new IllegalArgumentException("method.length() == 0");
        }

        public a e(String str, String str2) {
            c.c.b.a.b.v.a aVar = this.c;
            aVar.c(str, str2);
            aVar.a(str);
            aVar.a.add(str);
            aVar.a.add(str2.trim());
            return this;
        }

        public a f(URL url) {
            String url2 = url.toString();
            c.c.b.a.b.w.a aVar = new c.c.b.a.b.w.a();
            w wVar = null;
            if (aVar.a(null, url2) == c.c.b.a.b.w.a.a.SUCCESS) {
                wVar = aVar.b();
            }
            if (wVar != null) {
                b(wVar);
                return this;
            }
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("unexpected url: ");
            stringBuilder.append(url);
            throw new IllegalArgumentException(stringBuilder.toString());
        }

        public a g(String str, String str2) {
            c.c.b.a.b.v.a aVar = this.c;
            aVar.c(str, str2);
            aVar.a.add(str);
            aVar.a.add(str2.trim());
            return this;
        }

        public c0 h() {
            if (this.a != null) {
                return new c0(this);
            }
            throw new IllegalStateException("url == null");
        }

        public a(c0 c0Var) {
            this.a = c0Var.a;
            this.b = c0Var.b;
            this.d = c0Var.d;
            this.e = c0Var.e;
            this.c = c0Var.c.e();
        }
    }

    public c0(a aVar) {
        this.a = aVar.a;
        this.b = aVar.b;
        this.c = new v(aVar.c);
        this.d = aVar.d;
        Object obj = aVar.e;
        if (obj == null) {
            obj = this;
        }
        this.e = obj;
    }

    public i a() {
        i iVar = this.f;
        if (iVar != null) {
            return iVar;
        }
        iVar = i.a(this.c);
        this.f = iVar;
        return iVar;
    }

    public String toString() {
        StringBuilder g = c.b.a.a.a.g("Request{method=");
        g.append(this.b);
        g.append(", url=");
        g.append(this.a);
        g.append(", tag=");
        Object obj = this.e;
        if (obj == this) {
            obj = null;
        }
        g.append(obj);
        g.append('}');
        return g.toString();
    }
}
